Component({
  data: {
      statusCur: '',
      capsuleStyle: {},
      capsuleBack: {},
      opacityVal: 0,
      isFirstPage: true
  },
  options: {
      addGlobalClass: true,
      multipleSlots: true
  },
  properties: {
      // 新增title属性
      title: {
          type: String,
          value: ''
      },
      // 保留原有属性
      back: {
          type: Boolean,
          value: true
      },
      backtext: {
          type: String,
          value: ''
      },
      ui: {
          type: String,
          value: ''
      },
      bg: {
          type: String,
          value: 'bg-blur'
      },
      status: {
          type: String,
          value: ''
      },
      opacity: {
          type: Boolean,
          value: false
      },
      opacityChange: {
          type: Boolean,
          value: false
      },
      opacityBg: {
          type: Boolean,
          value: false
      },
      noFixed: {
          type: Boolean,
          value: false
      },
      capsule: {
          type: Boolean,
          value: false
      },
      stopBack: {
          type: Boolean,
          value: false
      },
      placeholder: {
          type: Boolean,
          value: true
      },
      isSlot: {
          type: Boolean,
          value: false
      },
      isCenter: {
          type: Boolean,
          value: false
      },
      isRight: {
          type: Boolean,
          value: false
      },
      scrollTop: {
          type: Number,
          value: 0
      },
  },
  lifetimes: {
      ready() {
          const page = this.sys_isFirstPage();
          this.setData({isFirstPage: page});
          this.opacityStatus();
      },
  },
  observers: {
      'scrollTop'() {
          this.opacityStatus();
      },
  },
  methods: {
      // 添加getData方法
      getData() {
          return this.data;
      },
      
      // 判断是否为第一个页面
      sys_isFirstPage() {
          return getCurrentPages().length === 1;
      },
      
      opacityStatus() {
          let {scrollTop, sys_navBar} = this.data;
          let val = scrollTop > sys_navBar ? 1 : scrollTop * 0.01;
          this.setData({opacityVal: val})
      },
      
      _navBack() {
          if (this.data.stopBack) {
              this.triggerEvent("navBack");
          } else {
              this._backPage();
          }
      },
      
      _navHome() {
          this._toHome();
      },
      
      // 完善_backPage方法
      _backPage() {
          if (this.sys_isFirstPage()) {
              this._toHome();
          } else {
              wx.navigateBack({
                  delta: 1
              });
          }
      },
      
      // 完善首页跳转方法
      _toHome() {
          wx.switchTab({
              url: '/pages/home/home' // 与app.json中首页路径保持一致
          });
      }
  }
})